<template>
    <div class="component-manage-rebate-card text-small">
        <div class="avatar-box">
            <img class="avatar" :src="avatar" alt="" mode="aspectFill">
        </div>
        <div class="info-box">
            <div class="name text-normal">{{nickname}}</div>
            <div class="text-grey-color">
                <span>{{tilte}}</span>
                <span>{{priceCurrency}}</span>
            </div>
            <div class="text-grey-color">{{formatCreatedAt}} {{shop}}</div>
        </div>
        <div class="referrer-info">
            <div class="name">推荐人：{{referrer}}</div>
            <div class="rebate">
                <span>他的返利：</span>
                <span class="color-red">{{rebateCurrency}}元</span>
            </div>
            <div class="type">{{identity}}</div>
        </div>
    </div>
</template>

<script>
import {
    currency,
    dateChinaFormat,
} from '@/lib/utils';

export default {
    name: '',
    props: {
        avatar: {
            type: String,
        },
        nickname: {
            type: String,
        },
        title: {
            type: String,
        },
        shop: {
            type: String,
        },
        createdAt: {
            type: String,
        },
        price: {
            type: [ String, Number ],
        },
        referrer: {
            type: String,
        },
        rebate: {
            type: [ String, Number ],
        },
        identity: {
            type: String,
        },
    },
    computed: {
        /** 价格 */
        priceCurrency() {
            return this.price ? '￥' + currency(this.price) : '';
        },
        /** 价格 */
        rebateCurrency() {
            return this.rebate ? '￥' + currency(this.rebate) : '';
        },
        formatCreatedAt() {
            return this.createdAt ? dateChinaFormat(new Date(this.createdAt), 'Y-m-d H:i:s') : '';
        },
    },
};
</script>

<style lang="less">
@import "../../lib/style/mixins.less";

.component-manage-rebate-card {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    height: 92px;
    padding: 14px;
    margin-bottom: 12px;
    background-color: @white-color;
    border-radius: 5px;
    box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.4);
    .avatar-box {
        width: 46px;
        height: 46px;
        margin-right: 16px;
        .avatar {
            width: 100%;
            height: 100%;
            border-radius: 50%;
        }
    }
    .info-box {
        width: 170px;
    }
    .referrer-info {
        width: 100px;
    }
    .info-box,
    .referrer-info {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
}
</style>
